﻿using Server.Database;
using Server.Business.proto;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using MongoDB.Bson;
using System.Drawing;
using Server.Resource;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;

namespace Server.Business
{
    public class ProdConverter
    {

        public PrimaryProd ToPrimaryProd(ProdDB prod)
        {
            PrimaryProd.Builder builder = new PrimaryProd.Builder();
            builder.SetId(prod.Id.ToString());
            builder.SetProdClass(prod.ProdClass);
            builder.SetProdLabel(prod.ProdLabel);
            builder.SetProdPlace(prod.ProdPlace);
            builder.SetProdSeries(prod.ProdSeries);
            builder.SetProdVersion(prod.ProdVersion);
            builder.SetPhyColor(prod.PhyColor);
            builder.SetPhyDefend(prod.PhyDefend);
            builder.SetPhyImpact(prod.PhyImpact);
            builder.SetPhySize(prod.PhySize);
            builder.SetAdpClass(prod.AdpClass);
            builder.SetAdpColor(prod.AdpColor.ToString());
            builder.SetAdpCri(prod.AdpCri);
            builder.SetEleLgtPower(prod.EleLgtPower);
            builder.SetOptAngle(prod.OptAngle);
            builder.SetProjSetup(prod.ProjSetup);
            builder.SetBusMarket(prod.BusMarket);
            builder.SetPicFacade(prod.PicFacade);
            return builder.Build();
        }

        public Prod ToProd(ProdDB prod)
        {
            Prod.Builder builder = new Prod.Builder();
            builder.SetId(prod.Id.ToString());
            builder.SetProdClass(prod.ProdClass);
            builder.SetProdLabel(prod.ProdLabel);
            builder.SetProdPlace(prod.ProdPlace);
            builder.SetProdSeries(prod.ProdSeries);
            builder.SetProdVersion(prod.ProdVersion);
            builder.SetPhyColor(prod.PhyColor);
            builder.SetPhyDefend(prod.PhyDefend);
            builder.SetPhyImpact(prod.PhyImpact);
            builder.SetPhySize(prod.PhySize);
            builder.SetAdpClass(prod.AdpClass);
            builder.SetAdpColor(prod.AdpColor.ToString());
            builder.SetAdpCri(prod.AdpCri);
            builder.SetEleLgtPower(prod.EleLgtPower);
            builder.SetOptAngle(prod.OptAngle);
            builder.SetProjSetup(prod.ProjSetup);
            builder.SetBusMarket(prod.BusMarket);
            builder.SetPicFacade(prod.PicFacade);

            builder.SetProdOrgin(prod.ProdOrgin);
            builder.SetPhyMaterial(prod.PhyMaterial);
            builder.SetPhyWeight(prod.PhyWeight);
            builder.SetOptExplain(prod.OptExplain);
            builder.SetOptEff(prod.OptEff);
            builder.SetEleShock(prod.EleShock);
            builder.SetEleVoltage(prod.EleVoltage);
            builder.SetEleType(prod.EleType);
            builder.SetEleElecPower(prod.ElePower);
            builder.SetEleAllPower(prod.EleAllPower);
            builder.SetEleCtlType(prod.EleCtlType);
            builder.SetAdpVersion(prod.AdpVersion);
            builder.SetAdpOutput(prod.AdpOutput);
            builder.SetAdpPins(prod.AdpPins);
            builder.SetProjParts(prod.ProjParts);
            builder.SetProjSize(prod.ProjSize);
            builder.SetProjReport(prod.ProjReport);
            builder.SetProjBaikup(prod.ProjBaikup);

            builder.SetBusIn(prod.BusIn);
            builder.SetBusOut(prod.BusOut);
            builder.SetBusExpires(prod.BusExpires);

            builder.SetPicSize(prod.PicSize);
            builder.SetPicGrading(prod.PicGrading);
            builder.SetPicLive(prod.PicLive);

            return builder.Build();
        }
    }

    public class UserConverter
    {
        public User To(UserDB user)
        {
            User.Builder builder = new User.Builder();
            builder.SetId(user.Id.ToString());
            builder.SetName(user.Name);
            builder.SetPassword(user.Pwd);
            builder.SetRoleType(user.RoleType);
            return builder.Build();
        }
    }
}
